//
//  ThemePicker.swift
//  HeadlineNews
//
//  Created by han on 2019/7/22.
//  Copyright © 2019 han. All rights reserved.
//

import Foundation

// 由于需要保存copy，所以只能用class
class ThemePicker: NSObject, NSCopying {
    
    // 由于需要动态改变，所以保存的是闭包，而不是闭包的结果。每次调用时重新计算结果。
    public typealias ValueType = () -> Any?
    
    public var value: ValueType
    
    required public init(v: @escaping ValueType) {
        value = v
    }
    
    public func copy(with zone: NSZone?) -> Any {
        return type(of: self).init(v: value)
    }
}


/*
  关于主题改变，常改变的有
 1. 字体 UIFont: label.font, textField.font, textView.font
 2. UIImage: UIImageView, UIButton.image/backgroundImage,
 3. CGFloat: UIView.Alpha, CALayer.BorderWidth
 4. UIKeyboardAppearance: UISearchBar, UITextField, UITextView
 5. UIActivityIndicatorView.Style: UIActivityIndicatorView
 6. UIBarStyle: UINavigationBar,UITabBar, UIToolBar, UISearchBar
 7. UIStatusBarStyle: UIApplication
 8. UIScrollView.IndicatorStyle: UIScrollView
 9. CGColor: CALayer.backgroundColor/borderColor/shadowColor/strokeColor/fillColor
 10. UIColor:
 UIView.backgroundColor/tintColor,
 UIBarButtonItem.tintColor,
 UILabel.textColor/highlightedTextColor/shadowColor,
 UINavigationBar.barTintColor,
 UISearchBar.barTintColor,
 UITabBar.barTintColor,
 UIToolbar.barTintColor,
 UITableView.separatorColor/sectionIndexColor/sectionIndexBackgroundColor,
 UITextField.textColor,
 UITextView.textColor,
 UIProgressView.progressTintColor/trackTintColor,
 UIPageControl.pageIndicatorTintColor/currentPageIndicatorTintColor
 UIButton.titleColor
 UISwitch, UISlider, UIPopoverPresentationController.backgroundColor
 
 
 关于主题改变：
 可以通过var
 可以通过func，带参数UIControl.Stated,animated
 
 */

